package online_store.servlet;

import java.io.IOException;
import java.sql.Connection;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import online_store.model.bus.UserBus;
import online_store.model.dto.UserDTO;

public class UserServlet extends HttpServlet{
	
	private UserBus userBus;
	
	@Override
	public void init(ServletConfig config) throws ServletException {
		userBus = new UserBus();
	}
	
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		HttpSession session = request.getSession();
		
		String username = (String) session.getAttribute("username");
		UserDTO user = userBus.findByUsername(username);
		
		request.setAttribute("userDTO", user);
		RequestDispatcher rd = request.getRequestDispatcher("userDetail.jsp");
		rd.forward(request, response);
	}
	
	
	
}





